package com.herench.bs.agent.impl;

import com.herench.bs.agent.IInHosAgent;
import com.herench.bs.dao.*;
import com.herench.bs.support.CleverClinicContext;
import com.herench.bs.support.ResponseMessage;
import com.herench.bs.support.WsClientFactory;
import com.herench.bs.transfer.*;
import org.apache.cxf.endpoint.Client;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.*;

/**
 * Created by ThinkPad on 2019/3/26.
 */
@Component
@Transactional(readOnly = true)
public class InHosAgent implements IInHosAgent {

    //    public static final String HIS_WS_URL = "http://10.0.0.132:5527/BITCService.asmx?wsdl";
//    public static final String HIS_WS_URL = "http://oa.herench.com:48451/BitcService.asmx?wsdl";
//    public static final String HIS_WS_URL = "http://61.181.76.107:8077/BITCService.asmx?wsdl";
//    public static final String HIS_WS_URL = "http://192.168.0.109:9002/platformService?wsdl";

    @Value("${his_ws_url}")
    private String hisWsUrl;

    @Value("${callMethod}")
    private String callMethod;

// ceshi
//    public static final String HIS_WS_URL = "http://111.33.68.62:8072/platformService?wsdl";
// sizhongxin
//    public static final String HIS_WS_URL = "http://168.192.1.43:8025/BITCService.asmx?wsdl";
//    public static final String HIS_WS_URL = "http://192.168.200.160:5527/BITCService.asmx?wsdl";

//   xkzhengshi public static final String HIS_WS_URL = "http://192.168.200.164:8089/BITCService.asmx?wsdl";
//    public static final String APPOINT_WS_URL = "http://10.0.0.132:5526/BitcAppService.asmx?wsdl";


    @Autowired
    private CleverClinicContext cleverClinicContext;

    @Autowired
    private IDeptDao deptDao;

    @Autowired
    private IDeptClassTypeDao deptClassTypeDao;

    @Autowired
    protected IPersonDao personDao;

    @Autowired
    private IClinicAppointmentRecordDao clinicAppointmentRecordDao;

    @Autowired
    private IDoctorDao doctorDao;

    @Autowired
    private IBillingRecordDao billingRecordDao;

    @Autowired
    private IClinicChargeDetailsRecordDao clinicChargeDetailsRecordDao;

    @Autowired
    private IClinicChargeRecordDao clinicChargeRecordDao;


    /**
     * 提取患者基本信息：GetPatient()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getPatientInHos(String channelCode, String hospitalCode, String idNo, String outpOrInp) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);
        // 身份证号
        params.put("idNo", idNo);
        // 门诊住院标志（0:门诊、1:住院、默认：0）
        params.put("outpOrInp", outpOrInp);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);

        Transfer transfer = new GetPatientInHosTransfer(method, client, "GetPatient");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取的报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // 患者ID
            res.put("patientId", resMap.get("patientId"));
            // 住院号
            res.put("inpNo", resMap.get("inpNo"));
            // 证件类型代码
            res.put("credentialsType", resMap.get("credentialsType"));
            // 证件号
            res.put("credentialsNo", resMap.get("credentialsNo"));
            // 姓名
            res.put("name", resMap.get("name"));
            // 年龄
            res.put("age", resMap.get("age"));
            // 出生日期
            res.put("birthday", resMap.get("birthday"));
            // 性别，中文（男、女、未知）
            res.put("sex", resMap.get("sex"));
            // 户口住址
            res.put("address", resMap.get("address"));
            // 现住址
            res.put("currentAddress", resMap.get("currentAddress"));
            // 国籍
            res.put("citizenship", resMap.get("citizenship"));
            // 民族，中文（汉族，回族等）
            res.put("nation", resMap.get("nation"));
            // 籍贯
            res.put("nativePlace", resMap.get("nativePlace"));
            // 出生地，代码
            res.put("birthPlace", resMap.get("birthPlace"));
            // 邮政编码
            res.put("zipCode", resMap.get("zipCode"));
            // 手机号码
            res.put("phoneNumberHome", resMap.get("phoneNumberHome"));
            // 身份，中文
            res.put("identity", resMap.get("identity"));
            // 费别，中文
            res.put("chargeType", resMap.get("chargeType"));
            // 婚姻状况，代码
            res.put("maritalStatus", resMap.get("maritalStatus"));
            // 门诊绑定状态
            res.put("patBind", resMap.get("patBind"));
            // 身份证号
            res.put("idNo", resMap.get("idNo"));
            // 医保卡号
            res.put("insurCardNo", resMap.get("insurCardNo"));
            // 工作单位
            res.put("serviceAgency", resMap.get("serviceAgency"));
            // 联系人姓名
            res.put("nextOfKin", resMap.get("nextOfKin"));
            // 与联系人关系
            res.put("relationship", resMap.get("relationship"));
            // 联系人电话
            res.put("nextOfKinPhone", resMap.get("nextOfKinPhone"));
            // 联系人地址
            res.put("nextOfKinAddr", resMap.get("nextOfKinAddr"));
            // 联系人邮政编码
            res.put("nextOfKinZipCode", resMap.get("nextOfKinZipCode"));
            // 是否住院: 1:住院状态;0:非住院状态
            res.put("isInhos", resMap.get("isInhos"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "提取患者基本信息：成功 ");
            res.put(ResponseMessage.MESSAGE, "提取患者基本信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "提取患者基本信息：成功");
        }  else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "提取患者基本信息：成功");
            res.put(ResponseMessage.MESSAGE, "提取患者基本信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "提取患者基本信息：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 修改住院患者基本信息：UpdateInpPatient ()
     *
     * @param channelCode 系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param idNo 身份证号
     * @param patientId 患者ID
     * @param name 姓名
     * @param sex 性别，中文（男、女）
     * @param dateOfBirth 出生日期
     * @param birthPlace 出生地
     * @param mailingAddress 户口地址
     * @param currentAddress 现住址
     * @param zipCode 邮政编码
     * @param nativePlace 籍贯
     * @param phoneNumberHome 联系电话
     * @param citizenship 国籍
     * @param nation 民族
     * @param insurCardNo 医保卡号
     * @param serviceAgency 工作单位
     * @param nextOfKin 联系人姓名
     * @param relationship 与联系人关系
     * @param nextOfKinPhone 联系人电话
     * @param nextOfKinAddr 联系人地址
     * @param nextOfKinZipCode 联系人邮政编码
     * @param maritalStatus 婚姻状况
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> updateInpPatient(String channelCode, String hospitalCode, String idNo, String patientId, String name, String sex, String dateOfBirth, String birthPlace, String mailingAddress, String currentAddress, String zipCode, String nativePlace, String phoneNumberHome, String citizenship, String nation, String insurCardNo, String serviceAgency, String nextOfKin, String relationship, String nextOfKinPhone, String nextOfKinAddr, String nextOfKinZipCode, String maritalStatus) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);
        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 姓名
        params.put("name", name);
        // 性别，中文（男、女）
        params.put("sex", sex);
        // 出生日期
        params.put("dateOfBirth", dateOfBirth);
        // 出生地
        params.put("birthPlace", birthPlace);
        // 户口地址
        params.put("mailingAddress", mailingAddress);
        // 现住址
        params.put("currentAddress", currentAddress);
        // 邮政编码
        params.put("zipCode", zipCode);
        // 籍贯
        params.put("nativePlace", nativePlace);
        // 联系电话
        params.put("phoneNumberHome", phoneNumberHome);
        // 国籍
        params.put("citizenship", citizenship);
        // 民族
        params.put("nation", nation);
        // 医保卡号
        params.put("insurCardNo", insurCardNo);
        // 工作单位
        params.put("serviceAgency", serviceAgency);
        // 联系人姓名
        params.put("nextOfKin", nextOfKin);
        // 与联系人关系
        params.put("relationship", relationship);
        // 联系人电话
        params.put("nextOfKinPhone", nextOfKinPhone);
        // 联系人地址
        params.put("nextOfKinAddr", nextOfKinAddr);
        // 联系人邮政编码
        params.put("nextOfKinZipCode", nextOfKinZipCode);
        // 婚姻状况
        params.put("maritalStatus", maritalStatus);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 交易ID（调用HIS的方法名）
        Transfer transfer = new UpdateInpPatientTransfer(method, client, "UpdateInpPatient");
        // 参数设置
        Map<String, Object> resMap = transfer.transfer(params);

        // 获取的报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "修改患者基本信息：成功 ");
            res.put(ResponseMessage.MESSAGE, "修改患者基本信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "修改患者基本信息：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取患者住院清单汇总信息：GetInHosBillCollect()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param patientId 患者ID
     * @param idNo 身份证号
     * @param visitId 住院次数
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getInHosBillCollect(String channelCode, String hospitalCode, String patientId, String idNo, String visitId) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 患者ID
        params.put("patientId", patientId);
        // 身份证号
        params.put("idNo", idNo);
        // 住院次数
        params.put("visitId", visitId);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetInHosBillCollectTransfer(method, client, "GetInHosBillCollect");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            res.put("dataList", resMap.get("dataList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院清单汇总信息：成功 ");
            res.put(ResponseMessage.MESSAGE, "获取患者住院清单汇总信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院清单汇总信息：成功");
        }  else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院清单汇总信息：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者住院清单汇总信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院清单汇总信息：成功");
        }  else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 患者入院申请查询：GetAppointsInHos ()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param idNo 身份证号
     * @param patientId 患者ID
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getAppointsInHos(String channelCode, String hospitalCode, String idNo, String patientId, String startDate, String endDate) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);

        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 开始日期
        params.put("startDate", startDate);
        // 结束日期
        params.put("endDate", endDate);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetAppointsInHosTransfer(method, client, "GetAppointsInHos");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            // 申请信息
            res.put("dataList", resMap.get("dataList"));
            // 个性化需求信息
            res.put("dataRequireList", resMap.get("dataRequireList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "患者入院申请查询：成功");
            res.put(ResponseMessage.MESSAGE, "患者入院申请查询：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "患者入院申请查询：成功");
        }  else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "患者入院申请查询：成功");
            res.put(ResponseMessage.MESSAGE, "患者入院申请查询：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "患者入院申请查询：成功");
        }  else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 患者入院申请取消：DoCancelAppointInHos ()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param idNo         身份证
     * @param patientId    患者ID
     * @param hosAppId     入院申请ID
     * @param wxUserMobile 微信公众号注册手机号：微信消息推送用
     * @param patientName 患者姓名：微信消息推送用
     * @param appointmentTime 预约时间：微信消息推送用
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> doCancelAppointInHos(String channelCode, String hospitalCode, String idNo, String patientId, String hosAppId, String wxUserMobile, String patientName, String appointmentTime) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);
        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 入院申请ID
        params.put("hosAppId", hosAppId);
        // 微信公众号注册手机号：微信消息推送用
        params.put("wxUserMobile", wxUserMobile);
        // 患者姓名：微信消息推送用
        params.put("patientName", patientName);
        // 预约时间：微信消息推送用
        params.put("appointmentTime", appointmentTime);



        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new DoCancelAppointInHosTransfer(method, client, "DoCancelAppointInHos");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "患者入院申请取消：成功");
            res.put(ResponseMessage.MESSAGE, "患者入院申请取消：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "患者入院申请取消：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 患者提交入院申请：DoAppointInHos ()
     *
     * @param channelCode 系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param patientId 患者ID
     * @param visitId 入院次数
     * @param patientName 患者姓名
     * @param sex 性别
     * @param birthDate 出生日期
     * @param idNo 身份证号
     * @param zipCode 邮政编码
     * @param phoneNumber 联系电话
     * @param patientClass 入院方式
     * @param patAdmCondition 入院病情
     * @param admissionCause 入院目的
     * @param prepayment 押金金额
     * @param deptAddmissionTo 入院科室编码
     * @param clinicDiagnosis 门诊诊断
     * @param clinicId 门诊号
     * @param appInHosRequireId 预约入院个性需求ID
     * @param appInHosRequireOptionSeq 预约入院个性需求选项序
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> doAppointInHos(String channelCode, String hospitalCode, String patientId, String visitId, String patientName, String sex, String birthDate, String idNo, String zipCode, String phoneNumber, String patientClass, String patAdmCondition, String admissionCause, String prepayment, String deptAddmissionTo, String clinicDiagnosis, String clinicId, String appInHosRequireId, String appInHosRequireOptionSeq) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 患者ID
        params.put("patientId", patientId);
        // 入院次数
        params.put("visitId", visitId);
        // 患者姓名
        params.put("patientName", patientName);
        // 性别
        params.put("sex", sex);
        // 出生日期
        params.put("birthDate", birthDate);
        // 身份证号
        params.put("idNo", idNo);
        // 邮政编码
        params.put("zipCode", zipCode);
        // 联系电话
        params.put("phoneNumber", phoneNumber);
        // 入院方式
        params.put("patientClass", patientClass);
        // 入院病情
        params.put("patAdmCondition", patAdmCondition);
        // 入院目的
        params.put("admissionCause", admissionCause);
        // 押金金额
        params.put("prepayment", prepayment);
        // 入院科室编码
        params.put("deptAddmissionTo", deptAddmissionTo);
        // 门诊诊断
        params.put("clinicDiagnosis", clinicDiagnosis);
        // 门诊号
        params.put("clinicId", clinicId);
        // 预约入院个性需求ID
        params.put("appInHosRequireId", appInHosRequireId);
        // 预约入院个性需求选项序
        params.put("appInHosRequireOptionSeq", appInHosRequireOptionSeq);

        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new DoAppointInHosTransfer(method, client, "DoAppointInHos");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // 入院申请ID
            res.put("hosAppId", resMap.get("hosAppId"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "患者提交入院申请：成功");
            res.put(ResponseMessage.MESSAGE, "患者提交入院申请：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "患者提交入院申请：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取患者入院通知单：GetInpNotice ()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param patientId    患者ID
     * @param idNo         身份证号
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getInpNotice(String channelCode, String hospitalCode, String patientId, String idNo) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 患者ID
        params.put("patientId", patientId);
        // 身份证号
        params.put("idNo", idNo);

        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetInpNoticeTransfer(method, client, "GetInpNotice");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            res.put("dataList", resMap.get("dataList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者入院通知单：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者入院通知单：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者入院通知单：成功");
        }  else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者入院通知单：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者入院通知单：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者入院通知单：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 患者入院申请审核：VerifyAppointInHos ()
     *
     * @param channelCode   系统编码：微信前端区分医院用
     * @param hospitalCode  医院代码：微信后端区分医院用
     * @param idNo          身份证号
     * @param patientId     患者ID
     * @param hosAppId      入院申请ID
     * @param admissionDate 预计入院日期
     * @param bedNo         预计入院床位号
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> verifyAppointInHos(String channelCode, String hospitalCode, String idNo, String patientId, String hosAppId, String admissionDate, String bedNo) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 入院申请ID
        params.put("hosAppId", hosAppId);
        // 预计入院日期
        params.put("admissionDate", admissionDate);
        // 预计入院床位号
        params.put("bedNo", bedNo);

        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new VerifyAppointInHosTransfer(method, client, "VerifyAppointInHos");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "患者入院申请审核：成功");
            res.put(ResponseMessage.MESSAGE, "患者入院申请审核：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "患者入院申请审核：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 患者入院办理：CheckInHos()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param idNo          身份证号
     * @param patientId    患者ID
     * @param hosAppId     入院申请ID
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> checkInHos(String channelCode, String hospitalCode, String idNo, String patientId, String hosAppId) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 入院申请ID
        params.put("hosAppId", hosAppId);

        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new CheckInHosTransfer(method, client, "CheckInHos");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // 指引位置
            res.put("deptLocation", resMap.get("deptLocation"));
            // 是否需要补录数据
            res.put("isSupplement", resMap.get("isSupplement"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "患者入院办理：成功");
            res.put(ResponseMessage.MESSAGE, "患者入院办理：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "患者入院办理：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "患者入院办理：成功");
            res.put(ResponseMessage.MESSAGE, "患者入院办理：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "患者入院办理：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 开具电子住院证：CreateInpNotice()
     *
     * @param channelCode     系统编码：微信前端区分医院用
     * @param hospitalCode    医院代码：微信后端区分医院用
     * @param idNo            身份证号
     * @param patientId       患者ID
     * @param visitId         入院次数
     * @param week            住院周数
     * @param drugUser        是否使用药品
     * @param operation       手术种类
     * @param prepayment      预交金金额
     * @param enterDate       开证时间
     * @param serviceAgency   工作单位
     * @param patAdmCondition 入院病情
     * @param noticeDoctorEmp 开证医生工号
     * @param validityDate    有效日期
     * @param inDept          入院科室编码
     * @param clinicDiagnosis 门诊诊断
     * @param phoneNumber 联系电话
     * @param currentAddr 现住
     * @param isJz 是否急诊
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> createInpNotice(String channelCode, String hospitalCode, String idNo, String patientId, String visitId, String week, String drugUser, String operation, String prepayment, String enterDate, String serviceAgency, String patAdmCondition, String noticeDoctorEmp, String validityDate, String inDept, String clinicDiagnosis, String phoneNumber, String currentAddr, String isJz) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 入院次数
        params.put("visitId", visitId);
        // 住院周数
        params.put("week", week);
        // 是否使用药品
        params.put("drugUser", drugUser);
        // 手术种类
        params.put("operation", operation);
        // 预交金金额
        params.put("prepayment", prepayment);
        // 开证时间
        params.put("enterDate", enterDate);
        // 工作单位
        params.put("serviceAgency", serviceAgency);
        // 入院病情
        params.put("patAdmCondition", patAdmCondition);
        // 开证医生工号
        params.put("noticeDoctorEmp", noticeDoctorEmp);
        // 有效日期
        params.put("validityDate", validityDate);
        // 入院科室编码
        params.put("inDept", inDept);
        // 门诊诊断
        params.put("clinicDiagnosis", clinicDiagnosis);
        // 联系电话
        params.put("phoneNumber", phoneNumber);
        // 现住
        params.put("currentAddr", currentAddr);
        // 是否急诊
        params.put("isJz", isJz);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new CreateInpNoticeTransfer(method, client, "CreateInpNotice");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "开具电子住院证：成功");
            res.put(ResponseMessage.MESSAGE, "开具电子住院证：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "开具电子住院证：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }

    /**
     * 患者入院申请修改：UpdateAppointInHos()
     *
     * @param channelCode              系统编码：微信前端区分医院用
     * @param hospitalCode             医院代码：微信后端区分医院用
     * @param idNo                     身份证号
     * @param patientId                患者ID
     * @param hosAppId                 入院申请ID
     * @param appInHosRequireId        预约入院个性需求ID
     * @param appInHosRequireOptionSeq 预约入院个性需求选项序号
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> updateAppointInHos(String channelCode, String hospitalCode, String idNo, String patientId, String hosAppId, String appInHosRequireId, String appInHosRequireOptionSeq) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 入院申请ID
        params.put("hosAppId", hosAppId);
        // 预约入院个性需求ID
        params.put("appInHosRequireId", appInHosRequireId);
        // 预约入院个性需求选项序号
        params.put("appInHosRequireOptionSeq", appInHosRequireOptionSeq);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new UpdateAppointInHosTransfer(method, client, "UpdateAppointInHos");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "患者入院申请修改：成功");
            res.put(ResponseMessage.MESSAGE, "患者入院申请修改：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "患者入院申请修改：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "患者入院申请修改：成功");
            res.put(ResponseMessage.MESSAGE, "患者入院申请修改：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "患者入院申请修改：成功");
        }  else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取住院进度当前步骤信息：GetHosScheduleCurrentInfo()
     *
     * @param channelCode     系统编码：微信前端区分医院用
     * @param hospitalCode    医院代码：微信后端区分医院用
     * @param idNo            身份证号
     * @param patientId       患者ID
     * @param visitId         住院次数
     * @param hosScheduleType 进度类型
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getHosScheduleCurrentInfo(String channelCode, String hospitalCode, String idNo, String patientId, String visitId, String hosScheduleType) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 住院次数
        params.put("visitId", visitId);
        // 进度类型
        params.put("hosScheduleType", hosScheduleType);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetHosScheduleCurrentInfoTransfer(method, client, "GetHosScheduleCurrentInfo");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // 进度类型
            res.put("hosScheduleType", resMap.get("hosScheduleType"));
            // 进度步骤图片名
            res.put("hosScheduleImageName", resMap.get("hosScheduleImageName"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取住院进度当前步骤信息：成功");
            res.put(ResponseMessage.MESSAGE, "获取住院进度当前步骤信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取住院进度当前步骤信息：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取住院进度当前步骤信息：成功");
            res.put(ResponseMessage.MESSAGE, "获取住院进度当前步骤信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取住院进度当前步骤信息：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取住院进度详细信息：GetHosScheduleDetail()
     *
     * @param channelCode      系统编码：微信前端区分医院用
     * @param hospitalCode     医院代码：微信后端区分医院用
     * @param idNo              身份证号
     * @param patientId        患者ID
     * @param visitId          住院次数
     * @param hosScheduleType 进度类型
     * @param medAppId         病历复印预约ID
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getHosScheduleDetail(String channelCode, String hospitalCode, String idNo, String patientId, String visitId, String hosScheduleType, String medAppId) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 住院次数
        params.put("visitId", visitId);
        // 进度类型
        params.put("hosScheduleType", hosScheduleType);
        // 病历复印预约ID
        params.put("medAppId", medAppId);

        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetHosScheduleDetailTransfer(method, client, "GetHosScheduleDetail");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            res.put("dataList", resMap.get("dataList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取住院进度详细信息：成功");
            res.put(ResponseMessage.MESSAGE, "获取住院进度详细信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取住院进度详细信息：成功");
        }  else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取住院进度详细信息：成功");
            res.put(ResponseMessage.MESSAGE, "获取住院进度详细信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取住院进度详细信息：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取预约住院申请个性需求：GetAppInHosRequire()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getAppInHosRequire(String channelCode, String hospitalCode) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetAppInHosRequireTransfer(method, client, "GetAppInHosRequire");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            res.put("dataList", resMap.get("dataList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取预约住院申请个性需求：成功");
            res.put(ResponseMessage.MESSAGE, "获取预约住院申请个性需求：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取预约住院申请个性需求：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取预约住院申请个性需求：成功");
            res.put(ResponseMessage.MESSAGE, "获取预约住院申请个性需求：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取预约住院申请个性需求：成功");
        }  else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取患者住院每日清单列表(PDF版)：GetDailyBillDetailPDF()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param idNo         身份证号
     * @param patientId    患者ID
     * @param visitId      住院次数
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getDailyBillDetailPDF(String channelCode, String hospitalCode, String idNo, String patientId, String visitId) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);
        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 住院次数
        params.put("visitId", visitId);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetDailyBillDetailPDFTransfer(method, client, "GetDailyBillDetailPDF");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            res.put("dataList", resMap.get("dataList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院每日清单列表(PDF版)：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者住院每日清单列表(PDF版)：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院每日清单列表(PDF版)：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院每日清单列表(PDF版)：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者住院每日清单列表(PDF版)：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院每日清单列表(PDF版)：成功");
        }
        else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取患者住院末次住院信息：GetPatInHos()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param idNo          身份证号
     * @param patientId    患者ID
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getPatInHos(String channelCode, String hospitalCode, String idNo, String patientId) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);

        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetPatInHosTransfer(method, client, "GetPatInHos");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            res.put("dataList", resMap.get("dataList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院末次住院信息：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者住院末次住院信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院末次住院信息：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院末次住院信息：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者住院末次住院信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院末次住院信息：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取患者住院结算信息：GetInpSettleInfo()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param patientId    患者ID
     * @param visitId      住院次数
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getInpSettleInfo(String channelCode, String hospitalCode, String patientId, String visitId) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 患者ID
        params.put("patientId", patientId);
        // 住院次数
        params.put("visitId", visitId);

        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetInpSettleInfoTransfer(method, client, "GetInpSettleInfo");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // 患者ID
            res.put("patientId", resMap.get("patientId"));
            // 患者姓名
            res.put("name", resMap.get("name"));
            // 身份证号
            res.put("idNo", resMap.get("idNo"));
            // 住院次数
            res.put("visitId", resMap.get("visitId"));
            // 总费用
            res.put("costs", resMap.get("costs"));
            // 应交费用
            res.put("charges", resMap.get("charges"));
            // 实收费用
            res.put("payments", resMap.get("payments"));
            // 医保支付
            res.put("insurPay", resMap.get("insurPay"));
            // 个人自付
            res.put("ownPay", resMap.get("ownPay"));
            // 预交金总额
            res.put("totalPrepayment", resMap.get("totalPrepayment"));
            // 结算状态
            res.put("settleStatus", resMap.get("settleStatus"));
            // 患者确认结算退款方式
            res.put("settleRefundType", resMap.get("settleRefundType"));
            // 患者确认结算退款卡号
            res.put("settleRefundCardNo", resMap.get("settleRefundCardNo"));
            // 患者确认结算退款金额
            res.put("settleRefundAmount", resMap.get("settleRefundAmount"));
            // 患者确认时间
            res.put("confirmDateTime", resMap.get("confirmDateTime"));
            // 患者确认渠道
            res.put("confirmOperator", resMap.get("confirmOperator"));
            // 实际结算退款方式
            res.put("factSettleRefundType", resMap.get("factSettleRefundType"));
            // 实际结算退款卡号
            res.put("factSettleRefundCardNo", resMap.get("factSettleRefundCardNo"));
            // 实际结算退款金额
            res.put("factSettleRefundAmount", resMap.get("factSettleRefundAmount"));
            // 实际结算内部票号
            res.put("factSettleRcptNo", resMap.get("factSettleRcptNo"));
            // 实际结算交易流水号
            res.put("factSettleStreamNo", resMap.get("factSettleStreamNo"));
            // 实际操作时间
            res.put("factOperationDateTime", resMap.get("factOperationDateTime"));
            // 实际退款操作员ID
            res.put("factRefundOperatorNo", resMap.get("factRefundOperatorNo"));
            // 实际退款操作员姓名
            res.put("factRefundOperator", resMap.get("factRefundOperator"));
            // 无法结算退款原因
            res.put("noSettleReason", resMap.get("noSettleReason"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院结算信息：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者住院结算信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院结算信息：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院结算信息：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者住院结算信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院结算信息：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取病例套餐：GetMedPlanDict()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getMedPlanDict(String channelCode, String hospitalCode) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetMedPlanDictTransfer(method, client, "GetMedPlanDict");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            res.put("dataList", resMap.get("dataList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取病例套餐：成功");
            res.put(ResponseMessage.MESSAGE, "获取病例套餐：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取病例套餐：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取病例套餐：成功");
            res.put(ResponseMessage.MESSAGE, "获取病例套餐：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取病例套餐：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取患者病例复印费用：GetMedPrintFee()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param inpNo 住院号
     * @param visitId      入院次数
     * @param medPlanCode  病例套餐编码
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getMedPrintFee(String channelCode, String hospitalCode, String inpNo, String visitId, String medPlanCode) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 住院号
        params.put("inpNo", inpNo);
        // 入院次数
        params.put("visitId", visitId);
        // 病例套餐编码
        params.put("medPlanCode", medPlanCode);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetMedPrintFeeTransfer(method, client, "GetMedPrintFee");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // 复印张
            res.put("printPaperNum", resMap.get("printPaperNum"));
            // 复印费
            res.put("printFee", resMap.get("printFee"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者病例复印费用：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者病例复印费用：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者病例复印费用：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者病例复印费用：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者病例复印费用：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者病例复印费用：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 复印病历预约：DoAppointMedPrint()
     *
     * @param channelCode          系统编码：微信前端区分医院用
     * @param hospitalCode         医院代码：微信后端区分医院用
     * @param inpNo                 住院号
     * @param visitId               入院次数
     * @param patientName          患者姓名
     * @param sex                   性别
     * @param idNo                  身份证号
     * @param idCardFrontImage 患者身份证正面照片数据流
     * @param idCardBehindImage 患者身份证背面照片数据流
     * @param agentName            代办人姓名
     * @param agentRelationship   代办人与患者关系
     * @param agentIdNo            代办人身份证号
     * @param agentIdCardFrontImage 代办人身份证正面照片数据流
     * @param agentIdCardBehindImage 代办人身份证背面照片数据流
     * @param agentPhoneNumber    代办人电话
     * @param medClass             病历类型
     * @param medPlanCode          病历套餐编码(复印用途)
     * @param printPurposeDesc    复印用途描述
     * @param printNum             复印份数
     * @param memo                  备注
     * @param postWay               领取方式
     * @param payWay                支付方式
     * @param recipientName        收件人姓名
     * @param relationship         收件人与患者关系
     * @param postAddr              收件地址
     * @param recipientPhoneNumber 收件人电话
     * @param wxUserMobile 微信公众号注册手机号：微信消息推送用
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> doAppointMedPrint(String channelCode, String hospitalCode, String inpNo, String visitId, String patientName, String sex, String idNo, String idCardFrontImage, String idCardBehindImage, String agentName, String agentRelationship, String agentIdNo, String agentIdCardFrontImage, String agentIdCardBehindImage, String agentPhoneNumber, String medClass, String medPlanCode, String printPurposeDesc, String printNum, String memo, String postWay, String payWay, String recipientName, String relationship, String postAddr, String recipientPhoneNumber, String wxUserMobile) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 住院号
        params.put("inpNo", inpNo);
        // 入院次数
        params.put("visitId", visitId);
        // 患者姓名
        params.put("patientName", patientName);
        // 性别
        params.put("sex", sex);
        // 身份证号
        params.put("idNo", idNo);
        // 患者身份证正面照片数据流
        params.put("idCardFrontImage", idCardFrontImage);
        // 患者身份证背面照片数据流
        params.put("idCardBehindImage", idCardBehindImage);
        // 代办人姓名
        params.put("agentName", agentName);
        // 代办人与患者关系
        params.put("agentRelationship", agentRelationship);
        // 代办人身份证号
        params.put("agentIdNo", agentIdNo);
        // 代办人身份证正面照片数据流
        params.put("agentIdCardFrontImage", agentIdCardFrontImage);
        // 代办人身份证背面照片数据流
        params.put("agentIdCardBehindImage", agentIdCardBehindImage);
        // 代办人电话
        params.put("agentPhoneNumber", agentPhoneNumber);
        // 病历类型
        params.put("medClass", medClass);
        // 病历套餐编码(复印用途)
        params.put("medPlanCode", medPlanCode);
        // 复印用途描述
        params.put("printPurposeDesc", printPurposeDesc);
        // 复印份数
        params.put("printNum", printNum);
        // 备注
        params.put("memo", memo);
        // 领取方式
        params.put("postWay", postWay);
        // 支付方式
        params.put("payWay", payWay);
        // 收件人姓名
        params.put("recipientName", recipientName);
        // 收件人与患者关系
        params.put("relationship", relationship);
        // 收件地址
        params.put("postAddr", postAddr);
        // 收件人电话
        params.put("recipientPhoneNumber", recipientPhoneNumber);
        // 微信公众号注册手机号：微信消息推送用
        params.put("wxUserMobile", wxUserMobile);

        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new DoAppointMedPrintTransfer(method, client, "DoAppointMedPrint");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // 住院号
            res.put("inpNo", resMap.get("inpNo"));
            // 入院次数
            res.put("visitId", resMap.get("visitId"));
            // 患者姓名
            res.put("patientName", resMap.get("patientName"));
            // 性别
            res.put("sex", resMap.get("sex"));
            // 身份证号
            res.put("idNo", resMap.get("idNo"));
            // 患者身份证正面照片数据流
            res.put("idCardFrontImage", resMap.get("idCardFrontImage"));
            // 患者身份证背面照片数据流
            res.put("idCardBehindImage", resMap.get("idCardBehindImage"));
            // 代办人姓名
            res.put("agentName", resMap.get("agentName"));
            // 代办人与患者关系
            res.put("agentRelationship", resMap.get("agentRelationship"));
            // 代办人身份证号
            res.put("agentIdNo", resMap.get("agentIdNo"));
            // 代办人身份证正面照片数据流
            res.put("agentIdCardFrontImage", resMap.get("agentIdCardFrontImage"));
            // 代办人身份证背面照片数据流
            res.put("agentIdCardBehindImage", resMap.get("agentIdCardBehindImage"));
            // 代办人电话
            res.put("agentPhoneNumber", resMap.get("agentPhoneNumber"));
            // 病历类型
            res.put("medClass", resMap.get("medClass"));
            // 病历套餐编码(复印用途)
            res.put("medPlanCode", resMap.get("medPlanCode"));
            // 复印用途描述
            res.put("printPurposeDesc", resMap.get("printPurposeDesc"));
            // 复印份数
            res.put("printNum", resMap.get("printNum"));
            // 备注
            res.put("memo", resMap.get("memo"));
            // 领取方式
            res.put("postWay", resMap.get("postWay"));
            // 支付方式
            res.put("payWay", resMap.get("payWay"));
            // 收件人姓名
            res.put("recipientName", resMap.get("recipientName"));
            // 收件人与患者关系
            res.put("relationship", resMap.get("relationship"));
            // 收件地址
            res.put("postAddr", resMap.get("postAddr"));
            // 收件人电话
            res.put("recipientPhoneNumber", resMap.get("recipientPhoneNumber"));


            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "复印病历预约：成功");
            res.put(ResponseMessage.MESSAGE, "复印病历预约：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "复印病历预约：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 复印病历预约取消：DoCancelAppointMedPrint()
     *
     * @param channelCode  系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param medAppId     复印病历预约ID
     * @param inpNo        住院号
     * @param visitId      入院次数
     * @param patientName  患者姓名
     * @param sex          性别
     * @param idNo         身份证号
     * @param wxUserMobile 微信公众号注册手机号：微信消息推送用
     * @param appointmentTime 预约时间：微信消息推送用
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> doCancelAppointMedPrint(String channelCode, String hospitalCode, String medAppId, String inpNo, String visitId, String patientName, String sex, String idNo, String wxUserMobile, String appointmentTime) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 复印病历预约ID
        params.put("medAppId", medAppId);
        // 住院号
        params.put("inpNo", inpNo);
        // 入院次数
        params.put("visitId", visitId);
        // 患者姓名
        params.put("patientName", patientName);
        // 性别
        params.put("sex", sex);
        // 身份证号
        params.put("idNo", idNo);

        // 微信公众号注册手机号：微信消息推送用
        params.put("wxUserMobile", wxUserMobile);
        // 预约时间：微信消息推送用
        params.put("appointmentTime", appointmentTime);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new DoCancelAppointMedPrintTransfer(method, client, "DoCancelAppointMedPrint");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "复印病历预约取消：成功");
            res.put(ResponseMessage.MESSAGE, "复印病历预约取消：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "复印病历预约取消：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }



    /**
     * 复印病历预约查询：GetAppointMedPrint()
     *
     * @param channelCode          系统编码：微信前端区分医院用
     * @param hospitalCode         医院代码：微信后端区分医院用
     * @param idNo 身份证号
     * @param inpNo 住院号
     * @param visitId 住院次数
     * @param patientName 患者姓名
     * @param patientId 患者ID
     * @param recipientName 收件人姓名
     * @param recipientPhoneNumber 收件人电话
     * @param appointStatus 预约状态
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getAppointMedPrint(String channelCode, String hospitalCode, String idNo, String inpNo, String visitId, String patientName, String patientId, String recipientName, String recipientPhoneNumber, String appointStatus, String startDate, String endDate) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 住院号
        params.put("inpNo", inpNo);
        // 住院次数
        params.put("visitId", visitId);
        // 患者姓名
        params.put("patientName", patientName);
        // 患者ID
        params.put("patientId", patientId);
        // 收件人姓名
        params.put("recipientName", recipientName);
        // 收件人电话
        params.put("recipientPhoneNumber", recipientPhoneNumber);
        // 预约状态
        params.put("appointStatus", appointStatus);
        // 开始日期
        params.put("startDate", startDate);
        // 结束日期
        params.put("endDate", endDate);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetAppointMedPrintTransfer(method, client, "GetAppointMedPrint");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            res.put("dataList", resMap.get("dataList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "复印病历预约查询：成功");
            res.put(ResponseMessage.MESSAGE, "复印病历预约查询：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "复印病历预约查询：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "复印病历预约查询：成功");
            res.put(ResponseMessage.MESSAGE, "复印病历预约查询：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "复印病历预约查询：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }




    /**
     * 复印病历预约缴费：ChargeAppointMedPrint   ()
     *
     * @param channelCode 系统编码：微信前端区分医院用
     * @param hospitalCode 医院代码：微信后端区分医院用
     * @param medAppId 复印病历预约ID
     * @param cardNo 卡号
     * @param cardType 卡类型
     * @param moneyType 支付类别
     * @param streamNo 流水号
     * @param batchCode 批次号
     * @param authorizationCode 授权码
     * @param terminalNumber 终端编号
     * @param bankCode 银行编码
     * @param bankName 银行名称
     * @param reference 参考号
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> chargeAppointMedPrint(String channelCode, String hospitalCode, String medAppId, String cardNo, String cardType, String moneyType, String streamNo, String batchCode, String authorizationCode, String terminalNumber, String bankCode, String bankName, String reference) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 复印病历预约ID
        params.put("medAppId", medAppId);
        // 卡号
        params.put("cardNo", cardNo);
        // 卡类型
        params.put("cardType", cardType);
        // 支付类别
        params.put("moneyType", moneyType);
        // 流水号
        params.put("streamNo", streamNo);
        // 批次号
        params.put("batchCode", batchCode);
        // 授权码
        params.put("authorizationCode", authorizationCode);
        // 终端编号
        params.put("terminalNumber", terminalNumber);
        // 银行编码
        params.put("bankCode", bankCode);
        // 银行名称
        params.put("bankName", bankName);
        // 参考号
        params.put("reference", reference);



        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new ChargeAppointMedPrintTransfer(method, client, "ChargeAppointMedPrint");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "复印病历预约缴费：成功");
            res.put(ResponseMessage.MESSAGE, "复印病历预约缴费：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "复印病历预约缴费：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取患者预交金缴费记录： GetPrePayments()
     *
     * @param idNo 身份证号
     * @param patientId 患者ID
     * @param visitId 住院次数
     * @param rcptNo 内部交易号
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getPrePayments(String channelCode, String hospitalCode, String idNo, String patientId, String visitId, String rcptNo, String startDate, String endDate) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 住院次数
        params.put("visitId", visitId);
        // 内部交易号
        params.put("rcptNo", rcptNo);
        // 开始日期
        params.put("startDate", startDate);
        // 结束日期
        params.put("endDate", endDate);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetPrePaymentsTransfer(method, client, "GetPrePayments");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            res.put("dataList", resMap.get("dataList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者预交金缴费记录：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者预交金缴费记录：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者预交金缴费记录：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者预交金缴费记录：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者预交金缴费记录：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者预交金缴费记录：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }



    /**
     * 患者预交金缴纳： DoPrePayments()
     *
     * @param patientId 患者ID
     * @param visitId 住院次数
     * @param amount 缴费金额
     * @param payWay 缴费方式
     * @param transactType 交易类型
     * @param idNo 身份证号
     * @param winNo 窗口号
     * @param cardNo 卡号
     * @param cardType 卡类型
     * @param tranNo 合同号
     * @param moneyType 支付类别
     * @param streamNo 流水号
     * @param batchCode 批次号
     * @param authorizationCode 授权码
     * @param terminalNumber 终端编号
     * @param bankCode 银行编码
     * @param bankName 银行名称
     * @param reference 参考号
     * @param wxUserMobile 微信公众号注册手机号：微信消息推送用
     * @param patientName 患者姓名：微信消息推送用
     * @param inpNo 住院号：微信消息推送用
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> doPrePayments(String channelCode, String hospitalCode, String patientId, String visitId, String amount, String payWay, String transactType, String idNo, String winNo, String cardNo, String cardType, String tranNo, String moneyType, String streamNo, String batchCode, String authorizationCode, String terminalNumber, String bankCode, String bankName, String reference, String wxUserMobile, String patientName, String inpNo) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 患者ID
        params.put("patientId", patientId);
        // 住院次数
        params.put("visitId", visitId);
        // 缴费金额
        params.put("amount", amount);
        // 缴费方式
        params.put("payWay", payWay);
        // 交易类型
        params.put("transactType", transactType);
        // 身份证号
        params.put("idNo", idNo);
        // 窗口号
        params.put("winNo", winNo);
        // 卡号
        params.put("cardNo", cardNo);
        // 卡类型
        params.put("cardType", cardType);
        // 合同号
        params.put("tranNo", tranNo);
        // 支付类别
        params.put("moneyType", moneyType);
        // 流水号
        params.put("streamNo", streamNo);
        // 批次号
        params.put("batchCode", batchCode);
        // 授权码
        params.put("authorizationCode", authorizationCode);
        // 终端编号
        params.put("terminalNumber", terminalNumber);
        // 银行编码
        params.put("bankCode", bankCode);
        // 银行名称
        params.put("bankName", bankName);
        // 参考号
        params.put("reference", reference);

        // 微信公众号注册手机号：微信消息推送用
        params.put("wxUserMobile", wxUserMobile);
        // 患者姓名：微信消息推送用
        params.put("patientName", patientName);
        // 住院号：微信消息推送用
        params.put("inpNo", inpNo);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new DoPrePaymentsTransfer(method, client, "DoPrePayments");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // 内部交易
            res.put("rcptNo", resMap.get("rcptNo"));

            // 身份证号：Log 输出用
            res.put("idNo", resMap.get("idNo"));
            // 缴费金额：Log 输出用
            res.put("amount", resMap.get("amount"));
            // 微信公众号注册手机号：Log 输出用
            res.put("wxUserMobile", resMap.get("wxUserMobile"));
            // 患者姓名：Log 输出用
            res.put("patientName", resMap.get("patientName"));
            // 患者ID：Log 输出用
            res.put("patientId", resMap.get("patientId"));
            // 流水号：Log 输出用
            res.put("streamNo", resMap.get("streamNo"));
            // 住院号：Log 输出用
            res.put("inpNo", resMap.get("inpNo"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "患者预交金缴纳：成功");
            res.put(ResponseMessage.MESSAGE, "患者预交金缴纳：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "患者预交金缴纳：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }

    /**
     * 有床通知患者确认： ConfirmAppointBedInfo()
     *
     * @param idNo 身份证号
     * @param hosAppId 入院申请ID
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> confirmAppointBedInfo(String channelCode, String hospitalCode, String idNo, String hosAppId) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 入院申请ID
        params.put("hosAppId", hosAppId);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new ConfirmAppointBedInfoTransfer(method, client, "ConfirmAppointBedInfo");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "有床通知患者确认：成功");
            res.put(ResponseMessage.MESSAGE, "有床通知患者确认：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "有床通知患者确认：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }

    /**
     * 获取患者住院费用清单： GetHosBill()
     *
     * @param idNo 身份证号
     * @param patientId 患者ID
     * @param visitId 住院次数
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @return
     */    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getHosBill(String channelCode, String hospitalCode, String idNo, String patientId, String visitId, String startDate, String endDate) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 住院次数
        params.put("visitId", visitId);
        // 开始日期
        params.put("startDate", startDate);
        // 结束日期
        params.put("endDate", endDate);



        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetHosBillTransfer(method, client, "GetHosBill");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            res.put("dataList", resMap.get("dataList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院费用清单：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者住院费用清单：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院费用清单：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院费用清单：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者住院费用清单：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院费用清单：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 获取患者住院详细信息： GetPatAllInHos()
     *
     * @param idNo 身份证号
     * @param patientId 患者ID
     * @param visitId 住院次数
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @return
     */    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> getPatAllInHos(String channelCode, String hospitalCode, String idNo, String patientId, String visitId, String startDate, String endDate) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 患者ID
        params.put("patientId", patientId);
        // 住院标识
        params.put("visitId", visitId);
        // 开始日期
        params.put("startDate", startDate);
        // 结束日期
        params.put("endDate", endDate);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new GetPatAllInHosTransfer(method, client, "GetPatAllInHos");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            // JSON数组数据
            res.put("dataList", resMap.get("dataList"));

            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院详细信息：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者住院详细信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院详细信息：成功");
        } else if (Dialect.getSuccessfulZero().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "1403");
            res.put(ResponseMessage.MESSAGE_IN, "获取患者住院详细信息：成功");
            res.put(ResponseMessage.MESSAGE, "获取患者住院详细信息：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "获取患者住院详细信息：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }


    /**
     * 患者结算信息确认： confirmSettleInfo()
     *
     * @param idNo 身份证号
     * @param inpNo 住院号
     * @param visitId 住院次数
     * @param settleRefundType 患者确认结算退款方式
     * @param settleRefundCardNo 患者确认结算退款卡号
     * @param settleRefundAmount 患者确认结算退款金额
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, readOnly = false)
    public Map<String, Object> confirmSettleInfo(String channelCode, String hospitalCode, String idNo, String inpNo, String visitId, String settleRefundType, String settleRefundCardNo, String settleRefundAmount) throws Exception {
        Map<String, Object> res = new HashMap<>(16);

        // 调用胸科院内前置服务或公司内部测试服务的方法名
        String method = callMethod;
        if (method == null || method.isEmpty()) method = "send";


        // 拼接入参：微信
        Map<String, Object> params = new HashMap<>(16);
        // 系统编码：微信前端区分医院用
        params.put("channelCode", channelCode);
        // 医院代码：微信后端区分医院用
        params.put("hospitalCode", hospitalCode);

        // 身份证号
        params.put("idNo", idNo);
        // 住院号
        params.put("inpNo", inpNo);
        // 住院次数
        params.put("visitId", visitId);
        // 患者确认结算退款方式
        params.put("settleRefundType", settleRefundType);
        // 患者确认结算退款卡号
        params.put("settleRefundCardNo", settleRefundCardNo);
        // 患者确认结算退款金额
        params.put("settleRefundAmount", settleRefundAmount);


        // 获取服务的连接：HIS前置
        Client client = WsClientFactory.getInstance().getWsClient(hisWsUrl);
        // 调用服务[hisWsUrl]的方法
        Transfer transfer = new ConfirmSettleInfoTransfer(method, client, "ConfirmSettleInfo");

        Map<String, Object> resMap = transfer.transfer(params);

        // 获取报文的具体项目：HIS前置
        if (Dialect.getSuccessfulState().equals(resMap.get(ResponseMessage.RES_CODE))) {
            res.put(ResponseMessage.RES_CODE, "0");
            res.put(ResponseMessage.MESSAGE_IN, "患者结算信息确认：成功");
            res.put(ResponseMessage.MESSAGE, "患者结算信息确认：成功");
            res.put(ResponseMessage.MESSAGE_OUT, "患者结算信息确认：成功");
        } else {
            String executeMessage = (String) resMap.get("message");
            res.put(ResponseMessage.RES_CODE, "-1");
            res.put(ResponseMessage.MESSAGE_IN, executeMessage);
            res.put(ResponseMessage.MESSAGE, executeMessage);
            res.put(ResponseMessage.MESSAGE_OUT, executeMessage);
        }

        return res;
    }




}